package com.rzl.expense.common.core.domain.entity;

import com.rzl.expense.common.annotation.Excel;
import com.rzl.expense.common.annotation.Excel.ColumnType;
import com.rzl.expense.common.annotation.Excel.Type;
import com.rzl.expense.common.core.domain.BaseEntity;
import com.rzl.expense.common.xss.Xss;

import javax.validation.constraints.Email;
import javax.validation.constraints.NotBlank;
import javax.validation.constraints.Size;
import java.util.Arrays;
import java.util.Date;
import java.util.List;


/**
 * 用户对象 sys_user
 *
 * @author expense
 */
public class SysUser extends BaseEntity {
    private static final long serialVersionUID = 1L;

    /**
     * 用户ID
     */
    @Excel(name = "用户序号", cellType = ColumnType.NUMERIC, prompt = "用户编号")
    private Long userId;

    /**
     * 地市ID
     */
    @Excel(name = "地市ID", type = Type.IMPORT)
    private String regId;

    private String pregId;
    private Integer hasChild;

    private String regName;

    /**
     * 用户账号-登录名称
     */
    @Excel(name = "登录名称")
    private String userName;

    /**
     * 用户昵称-用户名
     */
    @Excel(name = "用户名称")
    private String nickName;

    /**
     * 用户类型
     */
    private String userType;

    /**
     * 用户邮箱
     */
    @Excel(name = "用户邮箱")
    private String email;

    /**
     * 手机号码
     */
    @Excel(name = "手机号码")
    private String phoneNumber;

    /**
     * 用户性别
     */
    @Excel(name = "用户性别", readConverterExp = "0=男,1=女,2=未知")
    private String sex;

    /**
     * 用户头像
     */
    private String avatar;

    /**
     * 密码
     */
    private String password;

    /**
     * 帐号状态（1正常 0停用）
     */
    @Excel(name = "帐号状态", readConverterExp = "1=正常,0=停用")
    private String status;

    /**
     * 删除标志（0代表存在 2代表删除）
     */
    private String delFlag;

    /**
     * 最后登录IP
     */
    @Excel(name = "最后登录IP", type = Type.EXPORT)
    private String loginIp;

    /**
     * 最后登录时间
     */
    @Excel(name = "最后登录时间", width = 30, dateFormat = "yyyy-MM-dd HH:mm:ss", type = Type.EXPORT)
    private Date loginDate;

    /**
     * 地市对象
     */
    private SysRegion region;

    /**
     * 角色对象
     */
    private List<SysRole> roles;
    private String roleName;

    /**
     * 角色组
     */
    private List<String> roleIds;

    /**
     * 岗位组
     */
    private Long[] postIds;

    /**
     * 角色ID
     */
    private Long roleId;

/* ******************* 集团用户相关的数据 ******************* */
    /**
     * 集团用户id
     */
    private String groupUserId;
    /**
     * 区县id
     */
    private String groupRegId;
    /**
     * 用户编码
     */
    private String groupUserCode;
    /**
     * 是否有效
     */
    private String groupIsValid;
    /**
     * SMAP账号
     */
    private String groupSmapId;
    /**
     * SMAP手机号码
     */
    private String groupPreferredMobile;
    /**
     * SMAP用户状态
     */
    private String groupSmapStatus;
    /**
     * SMAP数据变更时间
     */
    private Date groupChangeTime;
    /**
     * SMAP用户类型
     */
    private String groupSynKind;
    /**
     * SMAP操作类型
     */
    private String groupChangeType;
    /**
     * SMAP所属组织
     */
    private String groupOrgCode;
    /**
     * SMAP所属地市
     */
    private String groupCityName;
    /**
     * 省份标识
     */
    private String groupPrvId;
    /**
     * 最后更新时间
     */
    private Date groupLastModifyTime;

    public SysUser() {

    }

    public SysUser(Long userId) {
        this.userId = userId;
    }

    public Long getUserId() {
        return userId;
    }

    public void setUserId(Long userId) {
        this.userId = userId;
    }

    public boolean isAdmin() {
        return isAdmin(this.userId);
    }

    public static boolean isAdmin(Long userId) {
        return userId != null && 1L == userId;
    }

    public String getRegId() {
        return regId;
    }

    public void setRegId(String regId) {
        this.regId = regId;
    }


    public String getPregId() {
        return pregId;
    }

    public void setPregId(String pregId) {
        this.pregId = pregId;
    }

    public Integer getHasChild() {
        return hasChild;
    }

    public void setHasChild(Integer hasChild) {
        this.hasChild = hasChild;
    }

    @Xss(message = "用户昵称不能包含脚本字符")
    @Size(min = 0, max = 30, message = "用户昵称长度不能超过30个字符")
    public String getNickName() {
        return nickName;
    }

    public void setNickName(String nickName) {
        this.nickName = nickName;
    }

    @Xss(message = "用户账号不能包含脚本字符")
    @NotBlank(message = "用户账号不能为空")
    @Size(min = 0, max = 30, message = "用户账号长度不能超过30个字符")
    public String getUserName() {
        return userName;
    }

    public void setUserName(String userName) {
        this.userName = userName;
    }

    @Email(message = "邮箱格式不正确")
    @Size(min = 0, max = 50, message = "邮箱长度不能超过50个字符")
    public String getEmail() {
        return email;
    }

    public void setEmail(String email) {
        this.email = email;
    }

    @Size(min = 0, max = 11, message = "手机号码长度不能超过11个字符")
    public String getPhoneNumber() {
        return phoneNumber;
    }

    public void setPhoneNumber(String phoneNumber) {
        this.phoneNumber = phoneNumber;
    }

    public String getSex() {
        return sex;
    }

    public void setSex(String sex) {
        this.sex = sex;
    }

    public String getAvatar() {
        return avatar;
    }

    public void setAvatar(String avatar) {
        this.avatar = avatar;
    }

    public String getPassword() {
        return password;
    }

    public void setPassword(String password) {
        this.password = password;
    }

    public String getStatus() {
        return status;
    }

    public void setStatus(String status) {
        this.status = status;
    }

    public String getDelFlag() {
        return delFlag;
    }

    public void setDelFlag(String delFlag) {
        this.delFlag = delFlag;
    }

    public String getLoginIp() {
        return loginIp;
    }

    public void setLoginIp(String loginIp) {
        this.loginIp = loginIp;
    }

    public Date getLoginDate() {
        return loginDate;
    }

    public void setLoginDate(Date loginDate) {
        this.loginDate = loginDate;
    }

    public SysRegion getRegion() {
        return region;
    }

    public void setRegion(SysRegion region) {
        this.region = region;
    }

    public List<SysRole> getRoles() {
        return roles;
    }

    public void setRoles(List<SysRole> roles) {
        this.roles = roles;
    }


    public List<String> getRoleIds() {
        return roleIds;
    }

    public void setRoleIds(List<String> roleIds) {
        this.roleIds = roleIds;
    }

    public Long[] getPostIds() {
        return postIds;
    }

    public void setPostIds(Long[] postIds) {
        this.postIds = postIds;
    }

    public Long getRoleId() {
        return roleId;
    }

    public void setRoleId(Long roleId) {
        this.roleId = roleId;
    }

    public String getGroupRegId() {
        return groupRegId;
    }

    public void setGroupRegId(String groupRegId) {
        this.groupRegId = groupRegId;
    }

    public String getGroupUserCode() {
        return groupUserCode;
    }

    public void setGroupUserCode(String groupUserCode) {
        this.groupUserCode = groupUserCode;
    }

    public String getGroupSmapId() {
        return groupSmapId;
    }

    public void setGroupSmapId(String groupSmapId) {
        this.groupSmapId = groupSmapId;
    }

    public String getGroupPreferredMobile() {
        return groupPreferredMobile;
    }

    public void setGroupPreferredMobile(String groupPreferredMobile) {
        this.groupPreferredMobile = groupPreferredMobile;
    }

    public String getGroupSmapStatus() {
        return groupSmapStatus;
    }

    public void setGroupSmapStatus(String groupSmapStatus) {
        this.groupSmapStatus = groupSmapStatus;
    }

    public Date getGroupChangeTime() {
        return groupChangeTime;
    }

    public void setGroupChangeTime(Date groupChangeTime) {
        this.groupChangeTime = groupChangeTime;
    }

    public String getGroupSynKind() {
        return groupSynKind;
    }

    public void setGroupSynKind(String groupSynKind) {
        this.groupSynKind = groupSynKind;
    }

    public String getGroupChangeType() {
        return groupChangeType;
    }

    public void setGroupChangeType(String groupChangeType) {
        this.groupChangeType = groupChangeType;
    }

    public String getGroupOrgCode() {
        return groupOrgCode;
    }

    public void setGroupOrgCode(String groupOrgCode) {
        this.groupOrgCode = groupOrgCode;
    }

    public String getGroupCityName() {
        return groupCityName;
    }

    public void setGroupCityName(String groupCityName) {
        this.groupCityName = groupCityName;
    }

    public String getGroupPrvId() {
        return groupPrvId;
    }

    public void setGroupPrvId(String groupPrvId) {
        this.groupPrvId = groupPrvId;
    }

    public Date getGroupLastModifyTime() {
        return groupLastModifyTime;
    }

    public void setGroupLastModifyTime(Date groupLastModifyTime) {
        this.groupLastModifyTime = groupLastModifyTime;
    }

    public String getUserType() {
        return userType;
    }

    public void setUserType(String userType) {
        this.userType = userType;
    }

    public String getGroupUserId() {
        return groupUserId;
    }

    public void setGroupUserId(String groupUserId) {
        this.groupUserId = groupUserId;
    }

    public String getGroupIsValid() {
        return groupIsValid;
    }

    public void setGroupIsValid(String groupIsValid) {
        this.groupIsValid = groupIsValid;
    }

    public String getRegName() {
        return regName;
    }

    public void setRegName(String regName) {
        this.regName = regName;
    }

    public String getRoleName() {
        return roleName;
    }

    public void setRoleName(String roleName) {
        this.roleName = roleName;
    }
}
